package com.htl.exampro.base.exception;

import lombok.Getter;

import java.io.Serial;
import java.io.Serializable;

public class ExamProException extends RuntimeException implements Serializable {

    @Serial
    private static final long serialVersionUID = 5565760508056698922L;

    @Getter
    private int code;
    private String message;

    public ExamProException() {
        super();
    }

    public ExamProException(String message) {
        super(message);
        this.message = message;
    }

    public ExamProException(int code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public static void cast(CommonError commonError) {
        throw new ExamProException(commonError.getCode(), commonError.getMessage());
    }

    public static void cast(String message) {
        throw new ExamProException(message);
    }

    public static void cast(int code, String message) {
        throw new ExamProException(code, message);
    }

}
